package com.amado.course45mysql03.dao.impl;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.List;

import com.amado.course45mysql03.dao.RoleOptMappingDao;
import com.amado.course45mysql03.domain.RoleOptMapping;

public class RoleOptMappingImpl implements RoleOptMappingDao {

	@Override
	public boolean add(List<RoleOptMapping> t) {
		Connection conn = DBConnection.getConn();
		String sql = "insert into t_role_opt_mapping(role_code,opt_code)values(?,?)";
		PreparedStatement ps = null;
		try {
			ps = conn.prepareStatement(sql);
			for (RoleOptMapping temp : t) {
				ps.setString(1, temp.getRoleCode());
				ps.setString(2, temp.getOperationCode());
				ps.addBatch();
			}
			ps.executeBatch();
			return true;
		} catch (SQLException e) {
			e.printStackTrace();
		} finally {
			DBConnection.close(null, ps, conn);
		}
		return false;
	}

	@Override
	public boolean upadte(RoleOptMapping t) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean isExists(String roleCode) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean delete(String roleCode) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public RoleOptMapping getByCode(String roleCode) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<RoleOptMapping> listAll() {
		// TODO Auto-generated method stub
		return null;
	}
	
}
